package com.hank.controller;

import com.hank.dto.UserDTO;
import com.hank.util.JwtUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
 * @author gaoZhiHao
 * @date 2023/5/11 14:25
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @Resource
    private JwtUtils jwtUtils;

    /**
     * 测试生成JWT token
     */
    @PostMapping("/token")
    public String generateToken(@RequestBody UserDTO userDTO) {
        // 生成JWT token
        return jwtUtils.generateToken(userDTO);
    }

    /**
     * 测试解析JWT token
     */
    @GetMapping("/parse")
    public Object parseToken(@RequestParam String token) {
        // 解析JWT token
        return jwtUtils.parseToken(token);
    }
}
